<template>
  <div class="f-loading__mask" v-show="show">
    <div class='mb-20px f-loading__icon'>
      <div class="rect1"></div>
      <div class="rect2"></div>
      <div class="rect3"></div>
      <div class="rect4"></div>
      <div class="rect5"></div>
    </div>
    <p class="text-13px">加载中</p>
  </div>
</template>

<script setup lang="ts">
const props = defineProps({
  show: {
    type: Boolean,
    default: false
  }
})
</script>

<style lang="less" scoped>
.f-loading {
  &__mask {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1011;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #000;
    opacity: 0.7;
    color: rgb(25, 137, 250);
  }

  &__icon {
    width: 40px;
    height: 30px;
    text-align: center;
    font-size: 12px;

    .rect2 {
      // 使用厂商前缀 -webkit 或是-ms- 用于不支持 animation 和 transform 属性的浏览器
      -webkit-animation-delay: -1.1s;
      animation-delay: -1.1s;
    }

    .rect3 {
      -webkit-animation-delay: -1.0s;
      animation-delay: -1.0s;
    }

    .rect4 {
      -webkit-animation-delay: -0.9s;
      animation-delay: -0.9s;
    }

    .rect5 {
      -webkit-animation-delay: -0.8s;
      animation-delay: -0.8s;
    }
  }

  &__icon>div {
    background-color: rgb(25, 137, 250);
    height: 100%;
    width: 2px;
    display: inline-block;
    margin-right: 4px;

    -webkit-animation: stretchdelay 1.2s infinite ease-in-out;
    animation: stretchdelay 1.2s infinite ease-in-out;
  }

  @-webkit-keyframes stretchdelay {

    0%,
    40%,
    100% {
      -webkit-transform: scaleY(0.4)
    }

    20% {
      -webkit-transform: scaleY(1.0)
    }
  }

  @keyframes stretchdelay {

    0%,
    40%,
    100% {
      transform: scaleY(0.4);
      -webkit-transform: scaleY(0.4);
    }

    20% {
      transform: scaleY(1.0);
      -webkit-transform: scaleY(1.0);
    }
  }
}
</style>
